package cn.com.hellowood.dynamicdatasource;

import cn.com.hellowood.dynamicdatasource.modal.Product;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static void main(String[] args) throws IOException {
        String resource = "application.properties";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        try {
            Product product = sqlSession.selectOne("cn.com.hellowood.dynamicdatasource.mapper.ProductDao.select", 1);
        } finally {
            sqlSession.close();
        }
    }
}
